/**
 * el-form表单，自定义组件触发验证规则
 * 使用方法，change/blur，时执行
 * this._dispatch("ElFormItem", "el.form.change", [value]);
 */

export default {
    methods: {
        _dispatch(componentName, eventName, params) {
            var parent = this.$parent || this.$root
            var name = parent.$options.componentName

            while (parent && (!name || name !== componentName)) {
                parent = parent.$parent

                if (parent) {
                    name = parent.$options.componentName
                }
            }
            if (parent) {
                parent.$emit.apply(parent, [eventName].concat(params))
            }
        }
    }
}
